//class 和 typename可以互换，
#include <iostream>
class Util
{
public:
    template <class T>
    bool equal(T t1, T t2)
    {
        return t1 == t2;
    }
};
class my_int
{
public:
    int a;
    bool operator==(my_int d);//重载运算符
};

bool my_int::operator==(my_int d)
{
    if (a != d.a)
        return false;
    else
        return true;
}
int main()
{
    int a = 2, b = 2;
    my_int c, d;
    c.a = 2;
    d.a = 2;
    Util aab;
    std::cout << aab.equal<int>(a, b) << std::endl;
    std::cout << aab.equal(1, 1) << std::endl;
    std::cout << aab.equal<my_int>(c, d) << std::endl;
    // 这个也证明了有些时候编译器可以自动匹配
    // std::cout << aab.equal(a, b) << std::endl;
    // std::cout << aab.equal(1, 1) << std::endl;
    // std::cout << aab.equal(c, d) << std::endl;
    return 0;
}
